<%--
  Created by IntelliJ IDEA.
  User: luo
  Date: 2020/7/6
  Time: 18:42
  To change this template use File | Settings | File Templates.
--%>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>新增理赔信息管理</title>
    <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="static/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="static/lib/layui-v2.5.5/css/layui.css"  media="all">
    <style type="text/css">
        .layui-table-body,.layui-table-box,.layui-table-cell{
            overflow: visible;
        }
        /* 设置下拉框的高度与表格单元相同 */
        td .layui-table-cell .layui-form-select {
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
        .select-search-input {
            position: absolute;
            z-index: 2;
            width: 80%;
        }
        .layui-form-label{
            width: 140px  !important;
        }

    </style>
</head>
<body>
<fieldset class="layui-elem-field" style="padding: 30px;">
    <legend>理算基本信息</legend>
    <table lay-filter="adjustment" class="layui-hide" id="adjustment"></table>
</fieldset>

<fieldset class="layui-elem-field" style="padding: 30px;">
    <legend>新增理算信息</legend>
    <from lay-filter="addAdj" class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">理算编号:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" placeholder="自动获取,不可输入" lay-verify="adjustmentId" name="adjustmentId" id="adjustmentId" autocomplete="off" disabled="">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >赔案编号*:</label>
                <div class="layui-input-inline">
                    <input type="text" name="selectId" id="selectId" class="layui-input select-search-input" value="" onkeyup="search('#selectId','#claimmainid');" autocomplete="off">
                    <select name="claimmainid" id="claimmainid" lay-verify="claimmainid" lay-filter="claimmainid" autocomplete="off" class="layui-select" lay-search>

                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >事故责任比率:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="accidentliabilityratio" name="accidentliabilityratio" id="accidentliabilityratio" autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">车损失金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="carfeetotal" name="carfeetotal" id="carfeetotal" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" >物损失金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="materialfeetotal" name="materialfeetotal" id="materialfeetotal" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >人伤损失金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="peoplefeetotal" name="peoplefeetotal" id="peoplefeetotal" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >赔偿限额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="indemnitylimit" name="indemnitylimit" id="indemnitylimit" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" >费用赔付总金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="costsettlement" name="costsettlement" id="costsettlement" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >损失赔付总金额*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="losssettlement" name="losssettlement" id="losssettlement" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >赔付总金额*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="settlementtotal" name="settlementtotal" id="settlementtotal" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">已预付费用金额*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="prepaymoney" name="prepaymoney" id="prepaymoney" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >已预付损失金额*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="prepaylossmoney" name="prepaylossmoney" id="prepaylossmoney" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" >理算日志:</label>
                <textarea style="width: 275px;higth:100px;" placeholder="请输入内容" class="layui-textarea" lay-verify="adjustmentopinion" name="adjustmentopinion" id="adjustmentopinion" autocomplete="off"></textarea>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>理算详细信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">项目类型:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="itemtype" name="itemtype" id="itemtype" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">损失项目名称:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="lossname" name="lossname" id="lossname" autocomplete="off">
                </div>
            </div>
            <label class="layui-form-label">三者险分类:</label>
            <div class="layui-input-inline">
                <select name='risktype' lay-verify="risktype" id="risktype" lay-filter="risktype" lay-search='' style="text-align: center">
                    <option value="">请选择</option>
                    <option value="车险">车险</option>
                    <option value="物险">物险</option>
                    <option value="人险">人险</option>
                </select>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">损失物金额:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="losstotal" name="losstotal" id="losstotal" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item">

            <div class="layui-inline">
                <label class="layui-form-label">施救费用*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="suecharges" name="suecharges" id="suecharges" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">投保比例:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="insurancepercentage" name="insurancepercentage" id="insurancepercentage" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">绝对免赔率*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="absolutelyfranchise" name="absolutelyfranchise" id="absolutelyfranchise" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">绝对免赔额*:</label>
                <div class="layui-input-inline">
                    <input class="layui-input"  lay-verify="deductibleaverage" name="deductibleaverage" id="deductibleaverage" autocomplete="off">
                </div>
            </div>
        </div>
        <button type="botton" class="layui-btn layui-col-md-offset6" data-type="reload" id="addAdj">添加理算信息</button>
    </from>
</fieldset>

    <fieldset class="layui-elem-field" style="padding: 20px;">
        <legend>新增理赔信息</legend>
        <from lay-filter="case" class="layui-form" action="">
            <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">理赔编号:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" placeholder="自动获取,不可输入" lay-verify="settlementId" name="settlementId" id="settlementId" autocomplete="off" disabled="">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">派工工号:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="userId" name="userId" id="userId" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 150px">领取人:</label>
                <div class="layui-input-inline">
                    <input class="layui-input" lay-verify="receiptor" name="receiptor" id="receiptor" autocomplete="off">
                </div>
            </div>
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label" style="width: 150px">保单号*:</label>
                    <div class="layui-input-inline" style="width:150px;">
                        <input type="text" name="selectPolicy" id="selectPolicy" class="layui-input select-search-input" value="" onkeyup="search('#selectPolicy','#policyNum');" autocomplete="off">
                        <select name="policyNum" id="policyNum" lay-verify="policyNum" lay-filter="policyNum" autocomplete="off" class="layui-select" lay-search>

                        </select>
                    </div>
                </div>
          </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">赔付总金额:</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" lay-verify="amountMoney" name="amountMoney" id="amountMoney" autocomplete="off">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px">车架号:</label>
                    <div class="layui-input-inline">
                        <input class="layui-input" placeholder="自动获取,不可输入" lay-verify="vin" name="vin" id="vin" autocomplete="off" disabled="">
                    </div>
                </div>

           </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">理赔方式*:</label>
                    <div class="layui-input-inline">
                        <select name='claimTyle' lay-verify="claimTyle" id="claimTyle" lay-filter="claimTyle" lay-search='' style="text-align: center">
                            <option value="">请选择</option>
                            <option value="转账">转账</option>
                            <option value="现金">现金</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px">理赔进展*:</label>
                    <div class="layui-input-inline">
                        <select name='claimEvolve' lay-verify="claimEvolve" id="claimEvolve" lay-filter="claimEvolve" lay-search='' style="text-align: center">
                            <option value="">请选择</option>
                            <option value="已完成" disabled>已完成</option>
                            <option value="查勘">查勘</option>
                            <option value="定损">定损</option>
                            <option value="审核">审核</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" style="width: 150px">理赔审核*:</label>
                    <div class="layui-input-inline">
                        <select name='settlementAudit' lay-verify="settlementAudit" id="settlementAudit" lay-filter="settlementAudit" lay-search='' style="text-align: center">
                            <option value="">请选择</option>
                            <option value="审核中">审核中</option>
                            <option value="审核通过" disabled>审核通过</option>
                            <option value="暂存" disabled>暂存</option>
                            <option value="撤销" disabled>撤销</option>
                        </select>
                    </div>
                </div>

            </div>
            <button type="botton" class="layui-btn layui-col-md-offset6" data-type="reload" id="search">添加理赔信息</button>
            <button type="reset" class="layui-btn a_back"><i class="layui-icon layui-icon-close" style="font-size: 24px; color:red;"></i>关闭页面</button>
      </from>
    </fieldset>

<script src="static/lib/assets/waifu-tips.js"></script>
<script src="static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>

<script>
    var line = "";
    getId("#policyNum", "claims/getWarrantyId","post", "选择保单号");//获取保单号
    getId("#claimmainid", "claims/getClaimMainId","post", "选择赔案号");//获取赔案号
    layui.use('table', function() {
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        form.render();

        table.on('row(adjustment)', function(obj){
            line = obj.data;
            //标注选中样式
            obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
        });
        table.on('rowDouble(adjustment)', function(obj){
            layer.open({
                type: 2,
                title:'理算详细信息',
                id: 'botn_2', //设定一个id，防止重复弹出
                skin: 'layui-layer-rim', //加上边框
                maxmin: true, //开启最大化最小化按钮
                area: ['90%', '70%'],
                content:"/claims/adjustmentDetail"
            });
        });

        table.render({
            elem: '#adjustment'
            ,url:'claims/getAdjustment'
            ,width: 1470
            ,cols: [[
                {field:'adjustmentid', minWidth:80, title: '理算编号', sort: true}
                ,{field:'claimmainid', minWidth:80, title: '赔案编号', sort: true}
                ,{field:'accidentliabilityratio', minWidth:80, title: '事故责任比率'}
                ,{field:'carfeetotal', minWidth:80, title: '车损失金额'}
                ,{field:'materialfeetotal', minWidth:100, title: '物损失金额'}
                ,{field:'peoplefeetotal', minWidth:120, title: '人伤损失金额'}
                ,{field:'indemnitylimit', minWidth:80, title: '赔偿限额'}
                ,{field:'costsettlement', minWidth:120, title: '费用赔付总金额'}
                ,{field:'losssettlement', minWidth:120, title: '损失赔付总金额'}
                ,{field:'settlementtotal', minWidth:120, title: '赔付总金额', sort: true}
                ,{field:'prepaymoney', minWidth:120, title: '已预付费用金额'}
                ,{field:'prepaylossmoney', minWidth:120, title: '已预付损失金额'}
                ,{field:'adjustmentopinion', minWidth:100, title: '理算日志'}
            ]]
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                ,groups: 5 //只显示 3 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
                ,limits: [2, 5, 10]
            }
            ,id:'adjustment'
        });

        $('.a_back').click(function () {
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

        //监听提交
        layui.$('#search').on('click', function(){
            var data = form.val('case');
            if(data.policyNum==""){
                layer.msg("该保单号不存在！")
            }else if(data.claimTyle==""){
                layer.msg("请选择理赔方式！")
            }else if(data.claimEvolve==""){
                layer.msg("请选择理赔进展！")
            }else if(data.settlementAudit==""){
                layer.msg("请选择理赔审核！")
            }else{
                layer.open({
                    content: '确认要新增理赔信息吗？'
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                        $.ajax({
                            url:'/claims/addClaims',
                            type:'post',
                            data: data,
                            dataType:"json",
                            success:function(data){
                                if(data.data==1){
                                    layer.msg(data.msg);
                                    setTimeout(function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        parent.layer.close(index);
                                        //修改成功后刷新父界面
                                        window.parent.location.reload();
                                    }, 800);
                                }
                                else{
                                    layer.msg(data.msg);
                                }
                            },
                            error:function(e){
                                layer.msg("新增失败！")
                            },

                        });
                        return false;
                    }
                    ,btn2: function(index, layero){
                        layer.close(index);
                    }
                });
            }
        });

        layui.$('#addAdj').on('click', function(){
            var data = form.val('addAdj');
            if(data.claimMainId==""){
                layer.msg("该赔案号不存在！")
            }else{
                layer.open({
                    content: '确认要新增理算信息吗？'
                    ,btn: ['确定', '取消']
                    ,yes: function(index, layero){
                        $.ajax({
                            url:'/claims/addAdjustment',
                            type:'post',
                            data: data,
                            dataType:"json",
                            success:function(data){
                                layer.msg(data.msg);
                                setTimeout(function () {
                                    //刷新界面
                                    window.location.reload();
                                }, 800);
                            },
                            error:function(e){
                                layer.msg("新增失败！")
                            },

                        });
                        return false;
                    }
                    ,btn2: function(index, layero){
                        layer.close(index);
                    }
                });
            }
        });
    });
    layui.use(['form', 'layedit','upload'], function () {
        var form = layui.form
        form.on('select(policyNum)', function (data) {   //选择并赋值给input框
            var txt = data.elem[data.elem.selectedIndex].text;
            $("#selectPolicy").val(txt);
            $("#policyNum").next().find("dl").css({ "display": "none" });
            form.render();
        });

        form.on('select(claimmainid)', function (data) {   //选择并赋值给input框
            var txt = data.elem[data.elem.selectedIndex].text;
            $("#selectId").val(txt);
            $("#claimmainid").next().find("dl").css({ "display": "none" });
            form.render();
        });

        window.search = function (selpolicy,policy) {
            var value = $(selpolicy).val();
            $(policy).val(value);
            form.render();
            $(policy).next().find("dl").css({ "display": "block" });
            var dl = $(policy).next().find("dl").children();
            var j = -1;
            for (var i = 0; i < dl.length; i++) {
                if (dl[i].innerHTML.indexOf(value) <= -1) {
                    dl[i].style.display = "none";
                    j++;
                }
                if (j == dl.length-1) {
                    $(policy).next().find("dl").css({ "display": "none" });
                }
            }
        }

    });
    //获取保单号，绑定到Select下拉框上
    function getId(element, url, type, title) {
        $.ajax({
            url: url,
            type: type,
            datatype:"json",
            success: function (data) {
                if (data != "" && data != null) {
                    var html1 = '<dd lay-value="" class="layui-select-tips layui-this">' + title + '</dd>';
                    var html2 = '<option value="" >' + title + '</option>';
                        for (var i = 0; i < data.length; i++) {
                            html1 += '<dd lay-value="' + data[i] + '">' + data[i] + '</dd>';
                            html2 += '<option value="' + data[i] + '">' + data[i] + '</option>';
                        }
                    $(element).next().children().eq(1).html(html1);
                    $(element).html(html2);
                }
            }
        })
    }
</script>
</body>
</html>
